﻿using System;

/// <summary>
/// 图片类
/// </summary>
public class Photo
{
    public string _PhotoName;
    public Photo() : this("无")
    {
    }
    public Photo(string Name)
    {
        _PhotoName = Name;
    }
    public string PhotoName
    {
        get { return _PhotoName; }
    }
}

/// <summary>
/// 相册类
/// </summary>
public class Album
{
    Photo[] photos;
    public Album() : this(5)
    {
    }
    public Album(int sum)
    {
        photos = new Photo[sum];
    }
    public Photo this[int index]
    {
        get
        {
            if (index < 0 || index >= photos.Length)
            {
                Console.WriteLine("错误索引！");
                return null;
            }
            return photos[index];
        }
        set
        {
            if (index < 0 || index >= photos.Length)
            {
                Console.WriteLine("错误索引！");
                return;
            }
            photos[index] = value;
        }
    }
    public Photo this[string Name]
    {
        get
        {
            foreach (Photo item in photos)
            {
                if (item.PhotoName == Name)
                    return item;
            }
            Console.WriteLine("没有{0}图片", Name);
            return null;
        }
    }
}


